import http from '../../http/http'
import * as url from '../../api/lyp_order_api'
const state = {
    tableAData:[],
    tableBData:[],

};
const actions = {
    getTableAData({commit}){
        return http({
            url:url.GETALLORDERDATA,
            method:'get'
        }).then(res=>{
            console.log(res.data.data)
            commit('addData',res.data.data)
            return res.data.data
        })
    },
    selectOrder({commit}){
        let newArr=[];
        let arr=this.tableAData
        let val=this.myinput
        for (let i=0;i<arr.length;i++){
            if (arr[i].orderId.toString().indexOf(val.myOrderId)>-1
                ||arr[i].channelId.indexOf(val.channelId)>-1
                ||arr[i].myOrderType.indexOf(val.myOrderType)>-1
                ||arr[i].orderState.indexOf(val.orderState)>-1
                ||arr[i].goodsName.indexOf(val.goodsName)>-1
                ||arr[i].buyerName.indexOf(val.buyerName)>-1
                ||arr[i].ordertime.indexOf(val.orderTime)>-1
                ||arr[i].sendType.indexOf(val.sendType)>-1
                ||arr[i].buyerTel.indexOf(val.buyerTel)>-1
            ){
                newArr.push(arr[i]);
            }
        }
        commit('getSelectData',newArr)
    }
};
const mutations = {
    addData(state,obj){
        state.tableAData = obj
        state.tableBData=obj.filter(item=> item.reword.content!=='')
    },
    getSelectData(state,obj){
        state.tableAData = obj
    }
}
const  getters= {

};
export default {
    state,
    actions,
    mutations,
    getters
}